﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EncircleFTM
{
    public partial class InputDialog : Form
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public InputDialog()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Used to get or set input label
        /// </summary>
        public string InputLabel
        {
            get { return this.lblInputLabel.Text; }
            set { this.lblInputLabel.Text = value; }
        }

        /// <summary>
        /// Used to get or set dialog title
        /// </summary>
        public string Title
        {
            get { return this.Text; }
            set { this.Text = value; }
        }

        /// <summary>
        /// Used to get or set File name
        /// </summary>
        public string InputText
        {
            get { return this.txtFileName.Text; }
            set { this.txtFileName.Text = value; }
        }

        /// <summary>
        /// Set dialog result as OK
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        /// <summary>
        /// Set dialog result as CANCEL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        /// <summary>
        /// Press enter key to close the dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtFileName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter && txtFileName.Text.Trim().Length >0)
            {
                e.Handled = true;
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                e.Handled = false;
            }
        }

        /// <summary>
        /// Set default focus
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InputDialog_Load(object sender, EventArgs e)
        {
            this.txtFileName.Focus();
        }
    }
}
